package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseAttrInfo;
import com.atguigu.gmall.model.product.BaseCategory1;
import com.atguigu.gmall.model.product.BaseCategory2;
import com.atguigu.gmall.model.product.BaseCategory3;
import com.atguigu.gmall.product.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class ManageController {

    @Autowired
    private ManageService manageService;

    @GetMapping("getCategory1")
    public Result getCategory1(){
        List<BaseCategory1> list = manageService.getCategory1();
        return Result.ok(list);
    }

    @GetMapping("getCategory2/{category1Id}")
    public Result getCategory2(@PathVariable long category1Id){
        List<BaseCategory2> list = manageService.getCategory2(category1Id);
        return Result.ok(list);
    }

    @GetMapping("/getCategory3/{category2Id}")
    public Result getCategory3(@PathVariable(name = "category2Id") long category2Id){
        List<BaseCategory3> list = manageService.getCategory3(category2Id);
        return Result.ok(list);
    }

    //  根据分类Id 来获取到平台属性集合数据！
    @GetMapping("/attrInfoList/{category1Id}/{category2Id}/{category3Id}")
    public Result attrInfoList(@PathVariable long category1Id,
                               @PathVariable long category2Id,
                               @PathVariable long category3Id){
        List<BaseAttrInfo> list = manageService.attrInfoList(category1Id,category2Id,category3Id);
        return Result.ok(list);
    }

}
